package com.snopy.dll;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
import com.sun.jna.win32.StdCallLibrary;

/**
 * @author snopy
 * @description:
 * @classname JNADllCall
 * @date 2021/01/07 9:33
 * @email 77912204@qq.com
 */
public class JNADllCall {

    public interface CLibrary extends Library {
        // DLL文件默认路径为项目根目录，若DLL文件存放在项目外，请使用绝对路径

        CLibrary INSTANCE = (CLibrary) Native.loadLibrary("D:\\temp\\SiInterface.dll",
                CLibrary.class);
        int INIT(char[] perrg);
        // 声明将要调用的DLL中的方法（可以是多个方法）
        void BUSINESS_HANDLE(String inputData, StringBuilder outData);
    }
    public static String strFilePathSmartDevice = "D:\\temp\\SiInterface.dll";
    public static void main(String[] args) {
        System.setProperty("jna.encoding", "UTF-8");
        //StdCallDll.INSTANCE.printf("Hello, World!\n");
        StringBuilder str = new StringBuilder("1");
        CLibrary.INSTANCE.BUSINESS_HANDLE("123",str);
        System.out.println(str);
    }
}
